<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('抽成结算列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>会长名称：</label>
                                <input type="text" name="agentPerson"/>
                            </li>
                            <li>
                                <label>市县名称：</label>
                                <input type="text" name="rakerPerson"/>
                            </li>
                            <li>
                                <label>结算年度：</label>
                                <input type="text" name="periodYear"/>
                            </li>
                            <li>
                                <label>结算月度：</label>
                                <input type="text" name="periodMonth"/>
                            </li>
                            <li>
                                <label>结算状态：</label>
                                <select name="settleStatue" th:with="type=${@dict.getType('settle_statue')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>结算类型：</label>
                                <select name="settleType" th:with="type=${@dict.getType('settle_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>交易号：</label>
                                <input type="text" name="transactionId"/>
                            </li>
                            <li>
                                <label>结算人：</label>
                                <input type="text" name="settleName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:serviceOrderSettle:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:serviceOrderSettle:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:serviceOrderSettle:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:serviceOrderSettle:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:serviceOrderSettle:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:serviceOrderSettle:remove')}]];
        var settleStatueDatas = [[${@dict.getType('settle_statue')}]];
        var settleTypeDatas = [[${@dict.getType('settle_type')}]];
        var prefix = ctx + "zsyh/serviceOrderSettle";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "抽成结算",
                columns: [{
                    field: 'Number',
                    title: '序号',
                    align: 'center',
                    width: 20,
                    formatter: function (value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                    {
                        field: 'id',
                        title: '主键',
                        align: 'center',
                        visible: false
                    },
                    {
                        field: 'agentPerson',
                        align: 'center',
                        title: '会长名称'
                    },
                    {
                        field: 'rakerPerson',
                        align: 'center',
                        title: '市县名称'
                    },
                    {
                        field: 'periodYear',
                        align: 'center',
                        title: '结算年度'
                    },
                    {
                        field: 'periodMonth',
                        align: 'center',
                        title: '结算月度'
                    },
                    {
                        field: 'agentSettleMoney',
                        align: 'center',
                        title: '会长应结算金额'
                    },
                    {
                        field: 'rakerSettleMoney',
                        align: 'center',
                        title: '市县应结算金额'
                    },
                    {
                        field: 'settleStatue',
                        align: 'center',
                        title: '结算状态',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(settleStatueDatas, value);
                        }
                    },
                    {
                        field: 'settleType',
                        align: 'center',
                        title: '结算类型',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(settleTypeDatas, value);
                        }
                    },
                    {
                        field: 'transactionId',
                        align: 'center',
                        title: '交易号'
                    },
                    {
                        field: 'settleName',
                        align: 'center',
                        title: '结算人'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            //获取当前年月
                            var myDate = new Date();
                            var currentYear = myDate.getFullYear();
                            var currentMonth = myDate.getMonth() + 1;
                            if (row.settleStatue == "1" && (currentMonth != row.periodMonth)) {
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="orderSettle(\'' + row.id + '\')"><i class="fa fa-edit"></i>结算</a> ');
                            }
                            return actions.join('');
                        }
                    }]/*, onLoadSuccess: function (data) {
                    debugger;
                    var rows = data.rows;
                    for(var i=0;i<rows.length;i++){
                        if (rows[i].settleType =='1') {
                            $('#bootstrap-table').bootstrapTable('hideColumn', 'rakerPerson');//rakerPerson
                            $('#bootstrap-table').bootstrapTable('hideColumn', 'rakerSettleMoney');//rakerSettleMoney
                            $('#bootstrap-table').bootstrapTable('showColumn', 'agentPerson');//rakerPerson
                            $('#bootstrap-table').bootstrapTable('showColumn', 'agentSettleMoney');//rakerSettleMoney
                        }else{
                            $('#bootstrap-table').bootstrapTable('hideColumn', 'agentPerson');//rakerPerson
                            $('#bootstrap-table').bootstrapTable('hideColumn', 'agentSettleMoney');//rakerSettleMoney
                            $('#bootstrap-table').bootstrapTable('showColumn', 'rakerPerson');//rakerPerson
                            $('#bootstrap-table').bootstrapTable('showColumn', 'rakerSettleMoney');//rakerSettleMoney
                        }

                    }
                }*/
            };
            $.table.init(options);
        });

        function orderSettle(id) {
            $.modal.confirm("确定结算该月分红吗？", function() {
                debugger;
                var url =prefix + "/orderSettle";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data,function () {
                    $("#bootstrap-table").bootstrapTable('refresh');
                });
            });
        }

    </script>
</body>
</html>